'''
Created on 03.06.2011

@author: blaze
'''
#TODO: Implement property updates migration
class CommentEntry(object):
    def __init__(self, ticketId, time, author, newValue):
        self.ticketId = ticketId
        self.time = time
        self.author = author
        self.text = newValue
        
    def __str__(self):
        return "[%i]%s: %s" % (self.ticketId, self.author, self.text)

    def __lt__(self, other):
        return self.time < other.time
    def __gt__(self, other):
        return self.time > other.time
    def __eq__(self, other):
        return self.time == other.time
    def __le__(self, other):
        return self.time <= other.time
    def __ge__(self, other):
        return self.time >= other.time
    def __ne__(self, other):
        return self.time != other.time

class TicketComments(object):
    def __init__(self, ticketId):
        self.ticketId = ticketId
        self.comments = []
    
    def addComment(self, comment):
        if self.ticketId == comment.ticketId:
            self.comments.append(comment)
        else:
            print("Duplicate comment with id: " + comment.ticketId)
        
    def getComments(self):
        return self.comments
    
    def __len__(self):
        return len(self.comments)